package com.ssm.service.impl;

import com.ssm.dao.RecruitAppliesMapper;
import com.ssm.dao.RecruitInfoMapper;
import com.ssm.entity.RecruitApplies;
import com.ssm.entity.RecruitAppliesExample;
import com.ssm.entity.RecruitInfo;
import com.ssm.service.AppliesService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("appliesService")
public class AppliesServiceImpl implements AppliesService {
    @Resource(name = "recruitAppliesMapper")
    private RecruitAppliesMapper recruitAppliesMapper;
    @Override
    public List<RecruitApplies> listAllRecruitApplies() {
        return recruitAppliesMapper.selectByExample(new RecruitAppliesExample());
    }

    @Override
    public Integer createRecruitApplies(RecruitApplies recruitApplies) {
        return recruitAppliesMapper.insert(recruitApplies);
    }

    @Override
    public Integer update(RecruitApplies recruitApplies) {
        return recruitAppliesMapper.updateByPrimaryKey(recruitApplies);
    }

    @Override
    public Integer deleteRecruitApplies(int id) {
        return recruitAppliesMapper.deleteByPrimaryKey(id) ;
    }

    @Override
    public RecruitApplies getRecruitApplies(int id) {
        return recruitAppliesMapper.selectByPrimaryKey(id);
    }
    public Integer IsgetstudentidtoRecruitApplies(int studentid ){
        RecruitAppliesExample  recruitAppliesExample =new RecruitAppliesExample();
        recruitAppliesExample.or().andIdEqualTo(studentid);
        List<RecruitApplies> list= recruitAppliesMapper.selectByExample(recruitAppliesExample);
        if (list.isEmpty()){
            return 0;
        }
        return 1;
    }


}
